require 'google_drive'

module SpreadsheetToJson
  class Spreadsheet
    attr_reader :spreadsheet
    # Initalize the spreadsheet with options hash inlcuding access_token and spreadsheet_key
    def initialize(options = {})
      if options.empty?
        puts "Please pass the parameter options with keys 
          of access_token and spreadsheet_key"
        exit
      end
      session = GoogleDrive.login_with_oauth(options[:access_token])
      @spreadsheet = session.spreadsheet_by_key(options[:spreadsheet_key])
    end
  
    # Get a sheet by worksheet's id
    def get_sheet_by_id(worksheet_id=0)
      spreadsheet.worksheets[worksheet_id]
    end
  
    # Get a sheet by a worksheet's name
    def get_sheet_by_name(worksheet_name)
      spreadsheet.worksheet_by_title(worksheet_name)
    end
  end
end
